#include "AudioClipResource.h"

using namespace SolidityEngine;

AudioClipResource::AudioClipResource(const std::string& path, const std::string& name):
    Resource(path,name),
    AudioClip()
{
    //ctor
}

AudioClipResource::~AudioClipResource()
{
}

void AudioClipResource::Load()
{
    Mix_FreeChunk(_clip);
    _clip=Mix_LoadWAV(path.c_str());
    if(!_clip){
        throw "Error: Could not load audio!";
    }
    count++;
}

void AudioClipResource::UnLoad()
{
    count--;
    if(count<1){
        Mix_FreeChunk(_clip);
    }
}

AudioClipResource* AudioClipResource::_Clone()
{
    return new AudioClipResource(*this);
}
